package com.hyjoy.web.servlet;

import com.hyjoy.entity.Product;
import com.hyjoy.service.ProductService;
import com.hyjoy.service.impl.ProductServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by hyjoy on 2018/4/5.
 */
public class IndexServlet extends BaseServlet {

    @Override
    public String index(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ProductService productService = new ProductServiceImpl();
        try {
            List<Product> hots = productService.findHot();
            List<Product> news = productService.findNew();

            request.setAttribute("hList", hots);
            request.setAttribute("nList", news);
        } catch (Exception e) {
            e.printStackTrace();

        }
        return "/jsp/index.jsp";
    }
}
